package com.fresh.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fresh.common.ResponseResult;
import com.fresh.entity.FreshArea;
import com.fresh.qo.AreaQO;
import com.fresh.service.AreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/area")
public class AreaController {

    @Autowired
    private AreaService areaService;

    @GetMapping("/all")
    public ResponseResult all(){
        List<FreshArea> areaList = areaService.list();
        return ResponseResult.success(areaList);
    }

    @GetMapping("/goPage")
    public ResponseResult goPage(AreaQO areaQO){
        IPage<FreshArea> iPage = areaService.getByConditionAndPage(areaQO);
        return ResponseResult.success(iPage);
    }

    @PostMapping("/updateStatus")
    public ResponseResult updateStatus(@RequestBody FreshArea freshArea){
        areaService.updateStatusById(freshArea);
        return ResponseResult.success();
    }

}
